import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutterdemo/refresh/pull_to_refresh/pull2refresh_header.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

class Pull2RefreshFooter extends StatefulWidget {
  @override
  _Pull2RefreshFooterState createState() => _Pull2RefreshFooterState();
}

class _Pull2RefreshFooterState extends State<Pull2RefreshFooter> {
  final double _refreshHeight = 200.h;

  @override
  Widget build(BuildContext context) {
    return CustomFooter(
      builder: (BuildContext context,LoadStatus mode){
        Widget body ;
        if(mode==LoadStatus.idle){
          body =  StaticRefreshHeaderOrFooter();
        }
        else if(mode==LoadStatus.loading){
          body =  AnimateRefreshHeaderOrFooter();
        }
        else if(mode == LoadStatus.failed){
          body = Text("Load Failed!Click retry!");
        }
        else if(mode == LoadStatus.canLoading){
          body = StaticRefreshHeaderOrFooter();
        }
        return Container(
          color: Colors.grey,
          height: _refreshHeight,
          child: Center(child:body),
        );
      },
    );
  }
}
